package com.itheima.fanshe;

import com.itheima.domain.Student;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

/*
使用属性对象  设置和获取值
 */
public class Demo09 {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {
        Class<Student> clazz = (Class<Student>) Class.forName("com.itheima.domain.Student");
        Student student = clazz.getDeclaredConstructor().newInstance();

        Field name = clazz.getDeclaredField("name");
        name.setAccessible(true);
        System.out.println(name.get(student));
        name.set(student,"坤坤");
        System.out.println(name.get(student));


        System.out.println(student);

    }
}
